import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
/**
 * ImageViewer is the main class of the image viewer application. It builds
 * and displays the application GUI and initialises all other components.
 * 
 * To start the application, create an object of this class.
 * 
 * @author Michael Kolling and David J Barnes 
 * @version 0.1
 */
public class GUI
{
    private JFrame f;
    private JPanel p;
    private JButton b1;
    private JLabel lab;
    private JTextField t;
    private JMenu menu;
    private final JTextArea ta = new JTextArea();

    /**
     * Create an ImageViewer show it on screen.
     */
    public GUI()
    {
        makeFrame();
    }

    // ---- swing stuff to build the frame and all its components ----

    /**
     * Create the Swing frame and its content.
     */
    private void makeFrame()
    {
        f = new JFrame("KantineSimulatie");
        f.setVisible(true);
        f.setSize(600, 400);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        p = new JPanel();
        p.setLayout(new GridLayout(1, 3));

       

        b1 = new JButton("Simuleer");
        b1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int dagen = Integer.parseInt(t.getText());

                    //System.out.println(dagen);
                    KantineSimulatie kantinesim =  new KantineSimulatie();
                    kantinesim.simuleer(dagen);
                    ta.append(kantinesim.getTextgui());
                    ta.revalidate();
                }
            });
        lab = new JLabel ("Hoeveel dagen:");

        t = new JTextField();

            
            
        p.add(lab);
        p.add(t);
        p.add(b1);
        p.add(ta);

        Container contentPane = f.getContentPane();
        contentPane.setLayout(new BorderLayout());
        contentPane.add(p, BorderLayout. NORTH);
        contentPane.add(ta, BorderLayout. CENTER);
        contentPane.add(new JScrollPane(ta));
        //f.add(p);
    }

    private void makeFrame1()
    {
        f = new JFrame("KantineSimulatie");
        f.setVisible(true);
        f.setSize(600, 400);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        p = new JPanel();
        p.setLayout(new GridLayout(1, 3));

        b1 = new JButton("Simuleer");
        b1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int dagen = Integer.parseInt(t.getText());

                    //System.out.println(dagen);
                    KantineSimulatie kantinesim =  new KantineSimulatie();
                    kantinesim.simuleer(dagen);
                    ta.append(kantinesim.getTextgui());
                    ta.revalidate();
                }
            });
        lab = new JLabel ("Hoeveel dagen:");

        t = new JTextField();

            
            
        p.add(lab);
        p.add(t);
        p.add(b1);
        p.add(ta);

        Container contentPane = f.getContentPane();
        contentPane.setLayout(new BorderLayout());
        contentPane.add(p, BorderLayout. NORTH);
        contentPane.add(ta, BorderLayout. CENTER);
        contentPane.add(new JScrollPane(ta));
        //f.add(p);
    }

    private void makeMenuBar (JFrame f)
    {
        JMenuBar menuBar = new JMenuBar();
        f.setJMenuBar(menuBar);

        JMenu fileMenu = new JMenu ("artikel");
        JMenuItem openItem = new JMenuItem ("Voeg artikel toe");
       

    }

    
}

